package com.example.common.utils;

import cn.hutool.core.date.DateUtil;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.util.Date;

/**
 * @Author 王鹤蒲
 * @Date 2024 01 15
 */
public class JwtUtils {

    public static String genToken(String userId, String sign) {
        return JWT.create().withAudience(userId)
                .withExpiresAt(DateUtil.offsetHour(new Date(), 2))
                .withIssuedAt(new Date())
                .sign(Algorithm.HMAC256(sign));
    }
}
